fn main() {
    println!("Hello, world!");
    let mut s = String::from("Hello");
    s.push_str(", World");
    println!("{}", s);

    let s1 = String::from("Hello");
    let s2 = s1.clone();

    println!("{}, {}", s1, s2);

    let mut s1 = gives_ownership();
    let length = calc_len(&mut s1);
    println!("{}, {}", s1, length);
    let (s2, len) = calculate_length(s1);
    println!("str:{}, len:{}", s2, len);
    let s3 = takes_and_gives_back(s2);

}

fn gives_ownership() -> String {
    let some_string = String::from("hello");
    some_string
}

fn takes_and_gives_back(a_string: String) -> String {
    a_string
}

fn calculate_length(s : String) -> (String, usize) {
    let len = s.len();
    (s, len)
}

fn calc_len(s : &mut String) -> usize {
    s.push_str(", www");
    s.len()
}